package com.cyj.dream.admin.model.system;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cyj.dream.core.base.SysBaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @Description: 系统菜单实体类
 * @BelongsProject: dream-DreamChardonnay
 * @BelongsPackage: com.dream.DreamChardonnay.model.system
 * @Author: ChenYongJia
 * @CreateTime: 2021-04-16 09:10
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "dream_sys_module")
@TableName("dream_sys_module")
@ApiModel(value = "系统菜单实体类", description = "dream_sys_module 系统菜单实体类")
public class SysModule extends SysBaseEntity implements Serializable {
    
    @ApiModelProperty(value = "模块名称")
    @Column(columnDefinition = "varchar(128) COMMENT '模块名称'")
    private String sysModuleName;

    @ApiModelProperty(value = "模块icon")
    @Column(columnDefinition = "varchar(100) COMMENT '模块icon'")
    private String sysModuleIcon;

    @ApiModelProperty(value = "父模块编号", example = "1")
    @Column(nullable = false , columnDefinition = "bigint(20) COMMENT '父模块编号'")
    private Long sysModuleParentId;

    @ApiModelProperty(value = "模块路径")
    @Column(columnDefinition = "varchar(255) COMMENT '模块icon'")
    private String sysModulePath;

    @ApiModelProperty(value = "权重(建立了索引因为要排序优化)", example = "9999")
    @Column(nullable = false , columnDefinition = "bigint(20) COMMENT '权重(建立了索引因为要排序优化)'")
    private Long sysModuleWeight;

    @ApiModelProperty(value = "备注信息")
    @Column(columnDefinition = "varchar(255) COMMENT '备注信息'")
    private String sysModuleRemark;

    @JsonIgnore
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "角色关联信息")
    private Set<SysRole> rolesSet = new HashSet<>();

    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "模块index")
    private String sysModulesIndex = this.sysModuleName;

    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "是否选中")
    private boolean checked;

    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "子节点数据集合")
    private List<SysModule> children;

    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "判断是否为子节点")
    private Boolean isChildren = false;

    @Override
    public String toString() {
        return "SysModule{" +
                ", sysModuleName='" + sysModuleName + '\'' +
                ", sysModulesIcon='" + sysModuleIcon + '\'' +
                ", sysModulesParentId=" + sysModuleParentId +
                ", sysModulesPath='" + sysModulePath + '\'' +
                ", sysModulesWeight=" + sysModuleWeight +
                ", sysModulesRemark='" + sysModuleRemark + '\'' +
                ", sysModulesIndex='" + sysModulesIndex + '\'' +
                ", checked=" + checked +
                ", children=" + children +
                ", isChildren=" + isChildren +
                '}';
    }

}
